<?php
	require_once("../../../include/connect.php");
	require_once("../../../include/datetime.php");
	
	$url = $_POST['url'];
	$date = day_now();
	
	if( (($_FILES["file"]["type"] == "image/gif") || 
		 ($_FILES["file"]["type"] == "image/jpeg") ||
		 ($_FILES["file"]["type"] == "image/jpg") || 
		 ($_FILES["file"]["type"] == "image/pjpeg") || 
		 ($_FILES["file"]["type"] == "image/x-png") || 
		 ($_FILES["file"]["type"] == "image/png") ) && ($_FILES["file"]["size"] < 400000) )
	{
		if ($_FILES["file"]["error"] > 0)
    		header("Location:../index.php?p=up_img_banner&msg=err&info=".$_FILES["file"]["error"]."");
		else
			if (file_exists("../../../img/upload/".$_FILES["file"]["name"]))
		      header("Location:../index.php?p=up_img_banner&msg=exist&info=".$_FILES["file"]["name"]."");
    		else
				if($url != "")
				{
					move_uploaded_file($_FILES["file"]["tmp_name"], "../../../img/upload/banner/".$_FILES["file"]["name"]);
					
					$query = mysql_query(" INSERT INTO banner(content,url,date)
								VALUES('".$_FILES["file"]["name"]."', '$url', '$date') ");
					if($query)
						header("Location:../index.php?p=up_img_banner&msg=success");	
				}
      			else
					header("Location:../index.php?p=up_img_banner&msg=null");
					//echo $category."-".$name."-".$content."-".$url;
	}
	else
		header("Location:../index.php?p=up_img_banner&msg=err_type");	
		
?>
